package com.woniu.liuzhougov.itemQueryAndNotice.dynamicprovider;

import com.woniu.liuzhougov.authorityControl.pojo.User;
import com.woniu.liuzhougov.itemAndTask.pojo.CheckStatus;
import com.woniu.liuzhougov.itemAndTask.pojo.Item;
import com.woniu.liuzhougov.itemAndTask.pojo.Urgenry;
import org.apache.ibatis.jdbc.SQL;

public class QuerySx {

    public String findItems(CheckStatus checkStatus, User user, Urgenry urgency, Item item){
        SQL sql= new SQL().SELECT("*").FROM("tb_item").WHERE("item_type_id=1");
        if (urgency.getUrgenryId()!=null){
            sql.WHERE("item_urgency_id="+ urgency.getUrgenryId());
        }
        if (user.getUserId()!=null){
            sql.WHERE("item_founder_id="+user.getUserId());
        }
        if (checkStatus.getCheckStatusId()!=null){
            sql.WHERE("item_status_id="+checkStatus.getCheckStatusId());
        }
        return sql.toString();
    }


    public String findCityItems(CheckStatus checkStatus, User user, Urgenry urgency, Item item){
        SQL sql= new SQL().SELECT("*").FROM("tb_item").WHERE("item_type_id=2");
        if (urgency.getUrgenryId()!=null){
            sql.WHERE("item_urgency_id="+ urgency.getUrgenryId());
        }
        if (user.getUserId()!=null){
            sql.WHERE("item_founder_id="+user.getUserId());
        }
        if (checkStatus.getCheckStatusId()!=null){
            sql.WHERE("item_status_id="+checkStatus.getCheckStatusId());
        }
        return sql.toString();
       }


    }

